package com.it.data.network

import ADNMVo
import DictVo
import EquimentVo
import GWRunningStaticVo
import LoginVo
import PictureVo
import VersionVo
import com.it.common.bean.ResultBean
import com.it.data.manager.HttpManager
import com.it.data.network.req.DealOrderDetailDto
import com.it.data.network.req.DouQItemsDto
import com.it.data.network.req.DouQRecordDto
import com.it.data.network.req.IrrItemsDto
import com.it.data.network.req.IrrRecordDto
import com.it.data.network.req.LakeItemsDto
import com.it.data.network.req.LakeRecordDto
import com.it.data.network.req.LoginDto
import com.it.data.network.req.ProblemUploadDto
import com.it.data.network.req.PumpItemsDto
import com.it.data.network.req.PumpRecordDto
import com.it.data.network.req.ResItemsDto
import com.it.data.network.req.ResRecordDto
import com.it.data.network.req.RiverRecordDto
import com.it.data.network.req.RvItemsDto
import com.it.data.network.req.ShouBuItemsDto
import com.it.data.network.req.ShouBuRecordDto
import com.it.data.network.req.SluiceItemsDto
import com.it.data.network.req.SluiceRecordDto
import com.it.data.network.req.UpdateRsvrInfoDto
import com.it.data.network.req.WellItemsDto
import com.it.data.network.req.WellRecordDto
import com.it.data.network.rsp.CheckStateVo
import com.it.data.network.rsp.DictionariesVo
import com.it.data.network.rsp.GQStationVo
import com.it.data.network.rsp.GQYWXXVo
import com.it.data.network.rsp.InsertqueGQVo
import com.it.data.network.rsp.MenuVo
import com.it.data.network.rsp.MyWorkOrderVo
import com.it.data.network.rsp.NodeVo
import com.it.data.network.rsp.OpDictDataVo
import com.it.data.network.rsp.PageVo
import com.it.data.network.rsp.QuaTypeCountVo
import com.it.data.network.rsp.QuaTypeShellVo
import com.it.data.network.rsp.QuaTypeVo
import com.it.data.network.rsp.RsvrDetailVo
import com.it.data.network.rsp.RsvrVo
import com.it.data.network.rsp.SttpVo
import com.it.data.network.rsp.UnresolvedVo
import com.it.data.network.rsp.WaterRecordVo
import com.it.data.network.rsp.WrongRecVo
import com.it.data.network.rsp.WtGQVo
import okhttp3.MultipartBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.QueryMap
import retrofit2.http.Url


/**
 *  @Description：http接口
 *  @author：weishixiong
 *  @date：2023/3/27 16:07
 *
 */
interface Api {
    companion object {
        fun apiClient(): Api {
            return HttpManager.create(Api::class.java);
        }

        const val GET_GQSTATIONLIST = "api/biz/op/OpStbprpExt/getGQStationList"
        const val GET_WTGQ = "api/biz/op/OpQuestionInfo/getWtGQ"
    }

    /**
     * 登录
     * @param dto LoginDto
     * @return ResultBean<LoginVo>
     */
    @POST("api/sys/login")
    suspend fun login(@Body dto: LoginDto): ResultBean<LoginVo>


    @GET("api/biz/op/OpDictData/list")
    suspend fun opDictDataList(@QueryMap map: Map<String, String>): ResultBean<PageVo<List<OpDictDataVo>>>

    /**
     * 测站列表
     * @param url String
     * @return ResultBean<PageVo<List<GQStationVo>>>
     */
    @GET
    suspend fun getGQStationList(
        @Url url: String,
        @Query("addvcd") addvcd: String?,
        @Query("sttp") sttp: String?,
        @Query("projecttype") projecttype: String?,
        @Query("quedeal") quedeal: String?,
        @Query("stnm") stnm: String?,
    ): ResultBean<PageVo<List<GQStationVo>>>


    @GET("api/sys/menus/findMenuListByUserid")
    suspend fun findMenuListByUserid(@Query("userId") userId: String): ResultBean<List<MenuVo>>


    @GET("api/biz/rw/addvcd/getNodeByAd/{depId}")
    suspend fun getNodeByAd(@Path("depId") depId: String): ResultBean<List<NodeVo>>

    /**
     * 测站类型列表
     * @return ResultBean<List<SttpVo>>
     */
    @GET("api/biz/rw/dict/getSttp")
    suspend fun getSttp(): ResultBean<List<SttpVo>>


    /**
     * 测站详情
     * @param STCD String
     * @return ResultBean<GQYWXXVo>
     */
    @GET("api/biz/op/OpStbprpExt/getGQYWXX/{STCD}")//00001118
    suspend fun getGQYWXX(@Path("STCD") STCD: String): ResultBean<GQYWXXVo>

    /**
     * 运维记录列表
     * @param url String
     * @param trcd String? 行政区划
     * @param stcd String? 测站编码 或者名称
     * @param queType String? 运维类型
     * @param queDeal String? 解决状态 1 已经解决 0 未解决
     * @param type Int? 1 运维问题 2 运维巡检
     * @return ResultBean<PageVo<List<WtGQVo>>>
     */
    @GET
    suspend fun getWtGQ(
        @Url url: String,
        @Query("trcd") trcd: String?,
        @Query("stcd") stcd: String?,
        @Query("queType") queType: String?,
        @Query("queDeal") queDeal: String?,
        @Query("type") type: Int?,
    ): ResultBean<PageVo<List<WtGQVo>>>

    /**
     * 运维类型
     * @param sttp String?
     * @return ResultBean<List<QuaTypeVo>>
     */
    @GET("api/biz/op/OpDictData/getQuaType")//
    suspend fun getQuaType(@Query("sttp") sttp: String?): ResultBean<List<QuaTypeVo>>


    /**
     * 根据stcd获取站点图片列表
     */
    @GET("api/biz/op/OpStcdPic/getGQPicByStcd/{STCD}")//
    suspend fun getGQPicByStcd(@Path("STCD") STCD: String): ResultBean<List<PictureVo>>


    /**
     * 测站信息下拉框
     */
    @GET("api/biz/op/OpStbprpExt/getDictName/{mode}")//
    suspend fun getDictName(@Path("mode") mode: String): ResultBean<List<DictVo>>


    /**
     * 更新测站详情
     * @param dto LoginDto
     * @return ResultBean<String>
     */
    @PUT("api/biz/op/OpStbprpExt/updateGQYWXX")
    suspend fun updateGQYWXX(@Body vo: GQYWXXVo): ResultBean<String>


    /**
     * 一键上传文件
     *
     * @param multipartBody
     * @return
     */
    @POST("api/biz/op/OpStcdPic/saveGQStcdPic")
    suspend fun saveGQStcdPic(@Body multipartBody: MultipartBody): ResultBean<String>


    /**
     * 一键上传文件
     *
     * @param multipartBody
     * @return
     */
    @POST("api/biz/op/OpQuaPic/saveQuePic")
    suspend fun saveQuePic(@Body multipartBody: MultipartBody): ResultBean<String>


    @GET("api/biz/op/OpDictData/getQuaTypeSell")//
    suspend fun getQuaTypeSell(
        @Query("sttp") sttp: String,
        @Query("queId") queId: String
    ): ResultBean<List<QuaTypeShellVo>>


    /**
     * 运维上报
     * @param vo ProblemUploadDto
     * @return ResultBean<String>
     */
    @POST("api/biz/op/OpQuestionInfo/insertqueGQ")
    suspend fun insertqueGQ(@Body dto: ProblemUploadDto): ResultBean<InsertqueGQVo>


    @GET("api/biz/op/OpQuestionInfo/equipment")//
    suspend fun equipment(
        @Query("sttp") sttp: String,
        @Query("id") id: String,
        @Query("stcd") stcd: String,
    ): ResultBean<List<EquimentVo>>

    /**
     * 获取未解决的问题
     * @param stcd String
     * @param id String
     * @param sttp String
     * @return ResultBean<List<EquimentVo>>
     */
    @GET("api/biz/op/OpQuestionInfo/getUnresolved")
    suspend fun getUnresolved(
        @Query("stcd") stcd: String,
        @Query("id") id: String,
        @Query("sttp") sttp: String,
    ): ResultBean<UnresolvedVo>


    /**
     * 获取未解决的问题
     * @param stcd String
     * @param id String
     * @param sttp String
     * @return ResultBean<List<EquimentVo>>
     */
    @GET("api/biz/op/OpQuestionInfo/getResolved")
    suspend fun getResolved(
        @Query("stcd") stcd: String,
        @Query("id") id: String,
        @Query("sttp") sttp: String,
    ): ResultBean<UnresolvedVo>

    /**
     * 添加水库修改记录
     * @param dto ResRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertResRecord")
    suspend fun insertResRecord(
        @Body dto: ResRecordDto
    ): ResultBean<Any>

    /**
     * 水库列表
     * @param dto ResItemsDto
     * @return ResultBean<PageVo<List<ResItemVo>>>
     */
    @POST("gwapi/web/itemlist/getResItems")
    suspend fun getResItems(
        @Body dto: ResItemsDto
    ): ResultBean<PageVo<List<ResRecordDto>>>


    /**
     * 水库详情
     * @param id String
     * @return ResultBean<Any>
     */
    @GET("gwapi/web/itemlist/getResBasic/{id}")
    suspend fun getResBasic(
        @Path("id") id: String,
    ): ResultBean<ResRecordDto>


    /**
     * 添加河流修改记录
     * @param dto RiverRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertRiverRecord")
    suspend fun insertRiverRecord(
        @Body dto: RiverRecordDto
    ): ResultBean<Any>

    /**
     * 河流列表
     * @param dto RvItemsDto
     * @return ResultBean<PageVo<List<RiverRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getRvItems")
    suspend fun getRvItems(
        @Body dto: RvItemsDto
    ): ResultBean<PageVo<List<RiverRecordDto>>>

    /**
     * 河流详情
     * @param id String
     * @return ResultBean<RiverRecordDto>
     */
    @GET("gwapi/web/itemlist/getRiveBasic/{id}")
    suspend fun getRiveBasic(
        @Path("id") id: String,
    ): ResultBean<RiverRecordDto>


    /**
     * 添加湖泊修改记录
     * @param dto LakeRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertLakeRecord")
    suspend fun insertLakeRecord(
        @Body dto: LakeRecordDto
    ): ResultBean<Any>

    /**
     * 湖泊列表
     * @param dto LakeItemsDto
     * @return ResultBean<PageVo<List<LakeRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getLakeItems")
    suspend fun getLakeItems(
        @Body dto: LakeItemsDto
    ): ResultBean<PageVo<List<LakeRecordDto>>>


    /**
     * 湖泊基本信息查询
     * @param id String
     * @return ResultBean<LakeRecordDto>
     */
    @GET("gwapi/web/itemlist/getLakeBasic/{id}")
    suspend fun getLakeBasic(
        @Path("id") id: String,
    ): ResultBean<LakeRecordDto>


    /**
     * 添加水闸修改记录
     * @param dto SluiceRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/sluiceApply")
    suspend fun sluiceApply(
        @Body list: MutableList<SluiceRecordDto>
    ): ResultBean<Any>

    /**
     * 水闸列表
     * @param dto SluiceItemsDto
     * @return ResultBean<PageVo<List<SluiceRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getSluiceItems")
    suspend fun getSluiceItems(
        @Body dto: SluiceItemsDto
    ): ResultBean<PageVo<List<SluiceRecordDto>>>


    /**
     * 水闸详情
     * @param id String
     * @return ResultBean<SluiceRecordDto>
     */
    @GET("gwapi/web/itemlist/getSluiceBasic/{id}")
    suspend fun getSluiceBasic(
        @Path("id") id: String,
    ): ResultBean<SluiceRecordDto>

    @GET("gwapi/web/itemlist//getAfterSluiceParamApp")
    suspend fun getAfterSluiceParam(
        @Query("guid") guid: String?,
        @Query("type") type: String?,
    ): ResultBean<SluiceRecordDto>


    /**
     * 添加泵站修改记录
     * @param dto SluiceRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/pumpApply")
    suspend fun insertPumpRecord(
        @Body list: MutableList<PumpRecordDto>
    ): ResultBean<Any>

    /**
     * 泵站列表
     * @param dto PumpItemsDto
     * @return ResultBean<PageVo<List<PumpRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getPumpItems")
    suspend fun getPumpItems(
        @Body dto: PumpItemsDto
    ): ResultBean<PageVo<List<PumpRecordDto>>>


    /**
     * 泵站详情
     * @param id String
     * @return ResultBean<PumpRecordDto>
     */
    @GET("gwapi/web/itemlist/getPumpBasic/{id}")
    suspend fun getPumpBasic(
        @Path("id") id: String,
    ): ResultBean<PumpRecordDto>

    @GET("gwapi/web/itemlist/getAfterPumpParamApp")
    suspend fun getAfterPumpParam(
        @Query("guid") guid: String?,
        @Query("type") type: String?,
    ): ResultBean<PumpRecordDto>
    /**
     * 添加首部修改记录
     * @param dto PumpRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/shouBuApply")
    suspend fun insertShouBuRecord(
        @Body list: MutableList<ShouBuRecordDto>
    ): ResultBean<Any>

    /**
     * 获取首部列表
     * @param dto ShouBuItemsDto
     * @return ResultBean<PageVo<List<ShouBuRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getShouBuItems")
    suspend fun getShouBuItems(
        @Body dto: ShouBuItemsDto
    ): ResultBean<PageVo<List<ShouBuRecordDto>>>


    /**
     * 获取首部详情
     * @param id String
     * @return ResultBean<ShouBuRecordDto>
     */
    @GET("gwapi/web/itemlist/getShouBuBasic/{id}")
    suspend fun getShouBuBasic(
        @Path("id") id: String,
    ): ResultBean<ShouBuRecordDto>

    @GET("gwapi/web/itemlist/getAfterShouBuParamApp")
    suspend fun getAfterShouBuParam(
        @Query("guid") guid: String?,
        @Query("type") type: String?,
    ): ResultBean<ShouBuRecordDto>

    /**
     * 添加斗渠修改记录
     * @param dto DouQRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertDouQRecord")
    suspend fun insertDouQRecord(
        @Body dto: DouQRecordDto
    ): ResultBean<Any>

    /**
     * 斗渠列表
     * @param dto DouQItemsDto
     * @return ResultBean<PageVo<List<DouQRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getDouQItems")
    suspend fun getDouQItems(
        @Body dto: DouQItemsDto
    ): ResultBean<PageVo<List<DouQRecordDto>>>

    /**
     * 斗渠详情
     * @param id String
     * @return ResultBean<DouQRecordDto>
     */
    @GET("gwapi/web/itemlist/getDouQBasic/{id}")
    suspend fun getDouQBasic(
        @Path("id") id: String,
    ): ResultBean<DouQRecordDto>


    /**
     * 添加机井修改记录
     * @param dto IrrRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertWellRecord")
    suspend fun insertWellRecord(
        @Body dto: WellRecordDto
    ): ResultBean<Any>

    /**
     * 机井列表
     * @param dto WellItemsDto
     * @return ResultBean<PageVo<List<WellRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getWellItems")
    suspend fun getWellItems(
        @Body dto: WellItemsDto
    ): ResultBean<PageVo<List<WellRecordDto>>>


    /**
     * 机井详情
     * @param id String
     * @return ResultBean<WellRecordDto>
     */
    @GET("gwapi/web/itemlist/getWellBasic/{id}")
    suspend fun getWellBasic(
        @Path("id") id: String,
    ): ResultBean<WellRecordDto>


    /**
     * 添加灌区修改记录
     * @param dto IrrRecordDto
     * @return ResultBean<Any>
     */
    @POST("gwapi/web/itemlist/insertIrrRecord")
    suspend fun insertIrrRecord(
        @Body dto: IrrRecordDto
    ): ResultBean<Any>

    /**
     * 灌区工程列表
     * @param dto IrrItemsDto
     * @return ResultBean<PageVo<List<IrrRecordDto>>>
     */
    @POST("gwapi/web/itemlist/getIrrItems")
    suspend fun getIrrItems(
        @Body dto: IrrItemsDto
    ): ResultBean<PageVo<List<IrrRecordDto>>>

    /**
     * 灌区详情
     * @param id String
     * @return ResultBean<IrrRecordDto>
     */
    @GET("gwapi/web/itemlist/getIrrBasic/{id}")
    suspend fun getIrrBasic(
        @Path("id") id: String,
    ): ResultBean<IrrRecordDto>


    /**
     * 团级行政区划
     * @param id String
     * @return ResultBean<List<ADNMVo>>
     */
    @GET("gwapi/web/itemlist/getTuanAddvcd/{id}")
    suspend fun getTuanAddvcd(
        @Path("id") id: String,
    ): ResultBean<List<ADNMVo>>

    /**
     *师级行政区划
     * @return ResultBean<List<ADNMVo>>
     */
    @GET("gwapi/web/itemlist/getShiAddvcd")
    suspend fun getShiAddvcd(): ResultBean<List<ADNMVo>>


    /**
     * 获取字典枚举
     */
    @GET("gwapi/web/itemlist/getDictionaries/{type}")
    suspend fun getDictionaries(@Path("type") type: String): ResultBean<List<DictionariesVo>>


    //工单列表
    @GET("api/opOrdersDetail/getListByUserId")//
    suspend fun getListByUserId(
        @Query("pageNo") pageNo: Int,
        @Query("pageSize") pageSize: Int,
        @Query("addvcd") addvcd: String?,
        @Query("status") status: String?,
        @Query("orderType") orderType: String?,
        @Query("stcd") stcd: String?,
    ): ResultBean<PageVo<List<MyWorkOrderVo>>>

    //工单详情
    @GET("api/opOrdersDetail/getOrderDetailById")//
    suspend fun getOrderDetailById(
        @Query("orderDetailId") orderDetailId: String
    ): ResultBean<MyWorkOrderVo>

    /**
     * 处理订单
     * @param vo DealOrderDetailDto
     * @return ResultBean<Any>
     */
    @PUT("api/opOrdersDetail/dealOrderDetail")
    suspend fun dealOrderDetail(@Body dto: DealOrderDetailDto): ResultBean<Any>

    //问题类型统计
    @GET("api/biz/op/OpQuestionInfo/quaTypeCount")//
    suspend fun quaTypeCount(
        @Query("startTime") startTime: String?,
        @Query("endTime") endTime: String?,
    ): ResultBean<List<QuaTypeCountVo>>


    //设备故障统计
    @GET("api/biz/op/OpQuestionInfo/getWrongRec")//
    suspend fun getWrongRec(
        @Query("startTime") startTime: String?,
        @Query("endTime") endTime: String?,
        @Query("pageNo") pageNo: Int,
        @Query("pageSize") pageSize: Int,
        @Query("equModel") equModel: String?
    ): ResultBean<PageVo<List<WrongRecVo>>>


    /**
     * 设备运行情况统计
     */
    @GET("api/biz/op/Maintain/OperationStatistics/{userId}")
    suspend fun OperationStatistics(
        @Path("userId") userId: String? = null,
        @Query("trcd") trcd: String?,
        @Query("onlineRate") onlineRate: String?,
        @Query("comments") comments: String?,
    ): ResultBean<List<GWRunningStaticVo>>


    @GET("api/sys/version")
    suspend fun version(): ResultBean<VersionVo>


    /**
     * 获取用户所管水库
     * @param id String
     * @return ResultBean<IrrRecordDto>
     */
    @GET("api/biz/rw/stbprp/selectUserManageRsvrList_APP")
    suspend fun selectUserManageRsvrList_APP(
        @Query("addvcd") addvcd: String,
    ): ResultBean<List<RsvrVo>>

    /**
     * 获取用户当日填写的数据
     * @param tm String
     * @return ResultBean<Any>
     */
    @GET("api/biz/rw/rsvr/getRsvrByStcdAndTm_APP")
    suspend fun getRsvrByStcdAndTm_APP(
        @Query("tm") tm: String,
        @Query("stcd") stcd: String,
    ): ResultBean<UpdateRsvrInfoDto>


    /**
     * 上报水情
     * @param dto IrrItemsDto
     * @return ResultBean<PageVo<List<IrrRecordDto>>>
     */
    @POST("api/biz/rw/rsvr/updateRsvrInfoV2")
    suspend fun updateRsvrInfo(
        @Body dto: UpdateRsvrInfoDto
    ): ResultBean<Any>


    /**
     * 查看已填水情
     * @param masterCd String
     * @param addvcd String
     * @param tm String
     * @return ResultBean<Any>
     */
    @GET("api/biz/rw/rsvr/getRsvrByAddvcdAndTm_APP")
    suspend fun getRsvrByAddvcdAndTm_APP(
        @Query("masterCd") masterCd: String,
        @Query("addvcd") addvcd: String,
        @Query("tm") tm: String,
    ): ResultBean<List<RsvrDetailVo>>

    /**
     * 水库上报  审核状态
     * @param tm String
     * @return ResultBean<Any>
     */
    @GET("api/biz/rw/sqsbcheck/getRsvrCheckStatus")
    suspend fun getCheckStateByTm(
        @Query("stcd") stcd: String?,
        @Query("date") date: String,
    ): ResultBean<CheckStateVo>


    @GET("api/sys/getCode")
    suspend fun getCode(
        @Query("phone") phone: String,
    ): ResultBean<Any>

    /**
     * 一键上传文件
     *
     * @param multipartBody
     * @return
     */
    @POST("gwapi/fileManage/upload")
    suspend fun upload(@Body multipartBody: MultipartBody): ResultBean<String>


    @GET("gwapi/web/itemlist/applicationList")
    suspend fun applicationList(
        @Query("trcd") trcd: String?,//行政区划编码
        @Query("style") style: String?,// 要素类型WAGA水闸SHBU首部PUST泵站
        @Query("stTm") stTm: String?,//开始时间
        @Query("enTm") enTm: String?,//结束时间
        @Query("state") state: String?,//审核状态1待审核2已审核3驳回
        @Query("stnm") stnm: String?,//测站名称
        @Query("addvcd") addvcd: String?,//用户行政区划编码（必传）
        @Query("pageSize") pageSize: Int,//
        @Query("pageNum") pageNum: Int,

        ): ResultBean<WaterRecordVo>

}